

function say() {
    alert("LC:682. 棒球比赛");
}
say();

/**
 * @param {string[]} ops
 * @return {number}
 */
var calPoints = function(ops) {
  //12:55-1:10
  var nunStack = []

  for(var i = 0; i < ops.length; i++){
    var item = ops[i]
    if(item == 'C'){
      nunStack.pop()
    }else if(item == 'D'){
      var last = nunStack[nunStack.length - 1] * 2
      nunStack.push(last)
    }else if(item == '+'){
      var last = nunStack[nunStack.length - 1]
      var pre = nunStack[nunStack.length - 2]
      nunStack.push(last + pre)
    }else {
      nunStack.push(parseInt(item))
    }
  }

  var res = nunStack[0]
  if(nunStack.length == 1){
    return res
  }else {
    for(var i = 1; i < nunStack.length; i++){
      res += nunStack[i]
    }
    return res
  }
};
